package com.admin.controllerv1;

import com.admin.fen.Adminfenmemediafeign;
import com.admin.mapper.AdChannelMapper;
import com.admin.service.AdChannelService;
import com.apis.channel.AdChannelControllerApi;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.dtos.NewsAuthDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.media.dtos.WmNewsPassDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(value = "频道管理",tags = "channel",description = "频道管理Apl")
@RequestMapping("/admin/api/v1/channel")
@RestController
public class AdChannelController implements AdChannelControllerApi {

    /**
     * 根据姓名去查询对应的channal中的数据
     * @param channelDto
     * @return
     */
    @Autowired
    private AdChannelService channelService;

    @Resource
    private AdChannelMapper channelMapper;

    @Resource
   private Adminfenmemediafeign adminfenmemediafeign;


    @PostMapping("list")
    @Override
    @ApiOperation(value = "频道查询",notes = "分页")
    @ApiImplicitParam(name = "channelDto",type = "ChannelDto",value = "分页参数")
    public ResponseResult findByNameAndPage(@RequestBody ChannelDto channelDto) {
        return channelService.findByNameAndPage(channelDto);
    }

    @GetMapping("qc")
    @Override
    public ResponseResult qc() {
        List<AdChannel> adChannels = channelMapper.selectList(null);
        return ResponseResult.okResult(adChannels) ;
    }

//    媒体审核查询
    @PostMapping("meitilist")
    @Override
    public ResponseResult meitilist(@RequestBody NewsAuthDto dto) {
        return adminfenmemediafeign.wzlisttu(dto);
    }


//    媒体回显
    @RequestMapping("meitihuixian/{id}")
    @Override
    public ResponseResult meitihuixian(@PathVariable Integer id) {
        return adminfenmemediafeign.meitihuixian(id);
    }

//    媒体通过 或者驳回
    @RequestMapping("pass")
    @Override
    public ResponseResult pass(@RequestBody WmNewsPassDto wmNewsPassDto) {
        return adminfenmemediafeign.pass(wmNewsPassDto);
    }

    @RequestMapping("fail")
    @Override
    public ResponseResult fail(@RequestBody WmNewsPassDto wmNewsPassDto) {
        return adminfenmemediafeign.fail(wmNewsPassDto);
    }


    /**
     * del:根据主键id  删除操作
     * @param id
     * @return
     */
    @GetMapping("del/{id}")
    @Override
    @ApiOperation(value = "频道删除",notes = "删除")
    @ApiImplicitParam(name = "id",type = "Integer",value = "删除参数")
    public ResponseResult del(@PathVariable Integer id) {
        return channelService.del(id);
    }

    /**
     * save :添加
     * @param adChannel
     * @return
     */
    @PostMapping("save")
    @Override
    @ApiOperation(value = "频道添加",notes = "添加")
    @ApiImplicitParam(name = "adChannel",type = "AdChannel",value = "添加参数")
    public ResponseResult save(@RequestBody AdChannel adChannel) {
        return channelService.saveAdChannel(adChannel);
    }

    /**
     * update:修改
     * @param adChannel
     * @return
     */
    @PostMapping("update")
    @Override
    @ApiOperation(value = "频道修改",notes = "修改")
//    多个参数 ApiImplicitParams
    @ApiImplicitParam(name = "adChannel",type = "AdChannel",value = "修改参数")
    public ResponseResult update(@RequestBody AdChannel adChannel) {
        return channelService.update(adChannel);
    }
}
